package com.example.binpacking.service.Impl;

import com.example.binpacking.mapper.InterviewContentMapper;
import com.example.binpacking.mapper.InterviewRecordMapper;
import com.example.binpacking.model.InterviewContent;
import com.example.binpacking.model.InterviewRecord;
import com.example.binpacking.service.OperationInterviewTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
@Service
public class OperationInterviewTableServiceImpl implements OperationInterviewTableService {
    @Autowired
    private InterviewRecordMapper interviewRecordMapper;
    @Autowired
    private InterviewContentMapper interviewContentMapper;
    @Override
    public void handleAction(String action, String id, String loginid) {
        switch (action) {
            case "add":
                addInterview(id, loginid);
                break;
            case "edit":
                editInterview(id, loginid);
                break;
            case "del":
                deleteInterview(id);
                break;
            case "cal":
                calculateSomething(id);
                break;
            default:
                throw new IllegalArgumentException("Unsupported action: " + action);
        }
        if (id != null) {
            addContent(id, loginid);
        }

    }

    @Override
    public void addInterview(String id, String loginid) {
        InterviewRecord interview = new InterviewRecord();
//        interview.setId(id);
//        interview.setLoginid(loginid);
        interviewRecordMapper.insert(interview);
    }

    @Override
    public void editInterview(String id, String loginid) {
        InterviewRecord interview = interviewRecordMapper.selectById(id);
        if (interview != null) {
//            interview.setLoginid(loginid);
            interviewRecordMapper.updateById(interview);
        }

    }

    @Override
    public void deleteInterview(String id) {
//        interviewRecordMapper.deletedByisdeleted(id);
    }

    @Override
    public void calculateSomething(String id) {
//        InterviewContent content = new InterviewContent();
//        content.setId(id);

    }

    @Override
    public void addContent(String id, String loginid) {
        InterviewContent content = new InterviewContent();
        content.setId(id);
        interviewContentMapper.insert(content);

    }
}
